null_function = function () {
    console.log(arguments[0], '调用空函数>>', arguments)
}

//补window环境
delete __dirname;// try{return __dirname;}catch(e){}
delete __filename; // try{return __filename;}catch(e){}
ActiveXObject = undefined; // 一定要

Window = function () {
}
window = self = parent = top = globalThis;
window.__proto__ = Window.prototype // "try{return (window instanceof Window);}catch(e){}"
window.name = ''
window.open = function () {
    console.log('window.open: >>', arguments)
}
window.TEMPORARY = 0
window.DOMParser = function () {
    console.log('window.DOMParser检查运行', arguments)
}
window.HTMLFormElement = function () {
    console.log('window中的HTMLFormElement：', arguments)
}
window.clientInformation = function () {
    console.log('window中的clientInformation：', arguments)
}
window.Request = function () {
    console.log('window.Request检查运行', arguments)
}
window.webkitRequestFileSystem = function (arg1, arg2, arg3, arg4) {
    console.log('window中的webkitRequestFileSystem：', arguments)
}
window.chrome = {
    "app": {
        "isInstalled": false,
        "InstallState": {
            "DISABLED": "disabled",
            "INSTALLED": "installed",
            "NOT_INSTALLED": "not_installed"
        },
        "RunningState": {
            "CANNOT_RUN": "cannot_run",
            "READY_TO_RUN": "ready_to_run",
            "RUNNING": "running"
        }
    }
}

addEventListener = function () {
    console.log('addEventListener >', arguments)
}
attachEvent = function () {
    console.log('attachEvent >', arguments)
}
indexedDB = {}

navigator = {
    webkitPersistentStorage: null_function('navigator.webkitPersistentStorage'),
    userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
    vendor: "Google Inc.",
    vendorSub: "",
    webdriver: false,
    product: "Gecko",
    productSub: "20030107",
    platform: "Win32",
    language: "zh-CN",
    languages: ['zh-CN'],
    appCodeName: "Mozilla",
    appName: "Netscape",
    appVersion: "5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
}

//补document
HTMLCollection = []
HTMLCollection.length = 0
div = {
    getElementsByTagName() {
        console.log('div.getElementsByTagName >', arguments)
        return HTMLCollection
    },
    innerHTML: '',

}
getAttribute = function () {
    console.log('getAttribute', arguments)
    if (arguments[0] == 'r') {
        return 'm'
    }
}
meta0 = {}
meta1 = {
    getAttribute: getAttribute,
    parentNode: {
        "removeChild": function () {
            console.log('meta1.parentNode.removeChild >>>', arguments)
        }
    },
    content: 'meta_content123',
    // content: content,
}
meta = [
    meta0,
    meta1,
]

script1 = {
    getAttribute: getAttribute,
    parentElement: {
        removeChild: function () {
            console.log('script1.parentElement.removeChild', arguments)
        }
    }
}

script2 = {
    getAttribute: getAttribute,
    parentElement: {
        removeChild: function () {
            console.log('script2.parentElement.removeChild', arguments)
        }
    }
}
script = [
    script1,
    script2,
]

webkitRequestFileSystem = null_function('webkitRequestFileSystem')
createElementObj = {}
getElementsByTagNameObj = {}
XMLHttpRequest = function () {
    console.log(arguments[0], '调用XMLHttpRequest>>', arguments)
}
XMLHttpRequest.prototype.open = function () {
    console.log(arguments[0], '调用XMLHttpRequest.prototype.open>>', arguments)
}
fetch = function () {
    console.log(arguments[0], '调用fetch>>', arguments)
}
fetch.toString = function () {
    return 'function fetch() { [native code] }'
}

XMLHttpRequest = function () {
    console.log(arguments[0], '调用XMLHttpRequest>>', arguments)
}
XMLHttpRequest.prototype.open = function () {
    // console.log(arguments[0],'调用XMLHttpRequest.prototype.open>>', arguments)
    return arguments
}


var elemA = {
    _href: '',
    set href(x) {
        console.log('set a href: ', x)
        if (!x.startsWith('http')) {
            if (x.startsWith('./')) {
                this._href = this.origin + '/' + x.replace('./', '')
            } else {
                this._href = this.origin + x
            }

        } else {
            this._href = x.replace(':443', '').replace(':80', '')
        }
    },
    get href() {
        console.log('get a href: ', this._href)
        return this._href
    },
    hostname: '', // webURL.split('://')[1]
    hash: '',
    origin: '', // webURL
    protocol: '', // webURL.split('//')[0]  http:
    pathname: "", // "/mall/service/query/QueryNavigations"
    port: '', // 80
    search: '', // ?mode=10

}

document = {
    characterSet: 'UTF-8',
    charset: 'UTF-8',
    createElement() {
        console.log('document.createElement >>>', arguments)
        if (arguments[0] === 'div') {
            return div
        } else if (arguments[0] == 'a') {
            return elemA
        }
        return createElementObj
    },
    getElementsByTagName() {
        console.log('document.getElementsByTagName >>>', arguments)
        if (arguments[0] === 'meta') {
            return meta
        } else if (arguments[0] == 'script') {
            return script
        }
        return getElementsByTagNameObj

    },
    exitFullscreen() {
        console.log('document.exitFullscreen >>>', arguments)
    },
    documentElement: {},
    addEventListener: addEventListener,
    attachEvent: attachEvent,
    cookie: '',
    getElementById: function () {
        console.log('document.getElementById >>>', arguments)
        if (arguments[0] == 'root-hammerhead-shadow-ui') {
            return null
        }
    },
    appendChild: function () { // 很重要
        console.log('document.appendChild检查运行', arguments)
    },
    removeChild: function () { // 很重要
        console.log('document.removeChild检查运行', arguments)
    }
}

screen = {}

history = {};

//补location
location = {
    "ancestorOrigins": {},
    "href": "https://www.nmpa.gov.cn/xxgk/ggtg/index_1.html",
    "origin": "https://www.nmpa.gov.cn",
    "protocol": "https:",
    "host": "www.nmpa.gov.cn",
    "hostname": "www.nmpa.gov.cn",
    "port": "",
    "pathname": "/xxgk/ggtg/index_1.html",
    "search": "",
    "hash": '',
}


localStorage = {
    removeItem(key) {
        console.log('localStorage.removeItem >>', arguments)
    },
    // "__#classType": "localStorage"
}
sessionStorage = {}
//
DOMParser = null_function('DOMParser')
setTimeout = function () {
    console.log('调用setTimeout', arguments)
}
setInterval = function () {
    console.log('调用setInterval', arguments)
}


document.visibilityState = 'visible'
document.all = [
    {},
    {},
    {},
    {},
]
;
'js_code'
//////////////////////////////////////////////////
;
;
;
require('./294cc83');

;
;
;
;
;
;

function getUrl(url, method = 'POST') {
    var urlObj = new URL(url);
    // console.log(urlObj)
    elemA.pathname = urlObj.pathname;
    elemA.search = urlObj.search;
    elemA.protocol = urlObj.protocol;
    elemA.origin = urlObj.origin;
    elemA.hostname = urlObj.hostname;
    var res = XMLHttpRequest.prototype.open(method, url, false)
    return res[1]
}

function main() {
    return document.cookie
}

// var result = main()
// console.log(result.length, result)
// var result = getUrl('https://www.10010.com/mall/service/query/QueryNavigations')
// console.log(result)
